var spinner;
//数据统计
function datastatis(map){
	var date = new Date();
	var seperator1 = "-";
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var strDate = date.getDate();
	if (month >= 1 && month <= 9) {
	    month = "0" + month;
	}
	if (strDate >= 0 && strDate <= 9) {
	    strDate = "0" + strDate;
	}
	var currentdate = year + seperator1 + month + seperator1 + strDate; 
	if(map==null){
		localStorage.setItem('timenow', JSON.stringify(currentdate));
		var map = {};
	}	
	localStorage.setItem('locklu', JSON.stringify("locklu"));
	var type = JSON.parse(localStorage.getItem('DetailsType'));
	var keys = JSON.parse(localStorage.getItem('key'));
	map.key = keys;
	map.page = 1;
	map.size = 20;
//	alert(map.timenow);
	var birthdayDate = JSON.parse(localStorage.getItem('birthdayDate'));
//	if(params == undefined) {
//		var paramsName = JSON.parse(localStorage.getItem('paramsNameDate'))
//		
//		map.startDate = paramsName;
//		map.endDate = paramsName;
//	} else if(params == "发情揭发成功率"){
//		type = 4;
//		map.startDate = birthdayDate;
//		map.endDate = birthdayDate;
//	}else if(params == "发情揭发比例"){
//		type = 5;
//		map.startDate = birthdayDate;
//		map.endDate = birthdayDate;
//	}else if(params == "发情漏检率"){
//		type = 6;
//		map.startDate = birthdayDate;
//		map.endDate = birthdayDate;
//	}else {
//		
//		map.startDate = params.name;
//		map.endDate = params.name;
//	}
	localStorage.setItem('DetailsType',JSON.stringify(''));
//	map.type = type;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
//	alert(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "datastatis",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb.data.length)
				if (bb.data.length > 0) {
					localStorage.setItem('datastatisData', JSON.stringify(bb.data));
					window.location = "数据统计.html";
				}else{
					mui.alert("暂无数据...")
				}
				
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
function getDateNow() {//--格式获取系统当前时间
	var date = new Date();
	var seperator1 = "-";
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var strDate = date.getDate();
	if (month >= 1 && month <= 9) {
		month = "0" + month;
	}
	if (strDate >= 0 && strDate <= 9) {
		strDate = "0" + strDate;
	}
	var currentdate = year + seperator1 + month + seperator1 + strDate;
	return currentdate;
}
function showDialog() {
	var opts = {
		lines: 13, // 花瓣数目
		length: 10, // 花瓣长度
		width: 5, // 花瓣宽度
		radius: 15, // 花瓣距中心半径
		scale: 1,
		corners: 1, // 花瓣圆滑度 (0-1)
		color: '#000', // 花瓣颜色
		opacity: 0.25,
		rotate: 0, // 花瓣旋转角度
		direction: 1, // 花瓣旋转方向 1: 顺时针, -1: 逆时针
		speed: 1, // 花瓣旋转速度
		trail: 60, // 花瓣旋转时的拖影(百分比)
		zIndex: 2e9, // spinner的z轴 (默认是2000000000)
		className: 'spinner', // spinner css 样式名称
		top: '350%', // spinner 相对父容器Top定位 单位 px
		shadow: false, // 花瓣是否显示阴影
		hwaccel: false, //spinner 是否启用硬件加速及高速旋转 
		position: 'absolute'
	};
	spinner = new Spinner(opts);
	$(".spin").show();
	var target = $(".spin")[0];
	spinner.spin(target);
}

function dismissDialog() {
	if(spinner != undefined) {
		spinner.spin();
	}
}

//登录接口
function logins() {
	if(null == document.getElementById("account").value || '' == document.getElementById("account").value) {
		mui.alert("请输入您的账号");
		return;
	}
	if(null == document.getElementById("password").value || '' == document.getElementById("password").value) {
		mui.alert("请输入您的密码");
		return;
	}
	var account = $("#account").val();
	var password = $("#password").val();
	var data = {
		"username": account,
		"password": password
	};
//	localStorage.clear();
	
	showDialog();
    var map = {};
    map.username = account;
    map.password = password;
    //极光推送token值
	var u = navigator.userAgent, app = navigator.appVersion;
	    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
	    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
	    if (isAndroid) {
	        var mainAct = plus.android.newObject("com.xcgame.jinniuxing.App");//测试为jinniuxingcs
	        map.app_sequence =  plus.android.invoke(mainAct,"getJPushID");
	    }
	    if (isIOS) {
	        map.app_sequence = localStorage.getItem('jpush');
	    }
	
    
//	alert(plus.android.invoke(mainAct,"getJPushID"))
    map.phoneType = "android";
    map.language = "zh";
    var jsonStr = JSON.stringify(map);
    console.log(url_prefix)
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "applogin",
		dataType: 'JSON',
		timeout: 10000,
		crossDomain: true,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			console.log(bb);
			if(bb.head.status == 1) {
				localStorage.setItem('account', JSON.stringify(account));
				localStorage.setItem('password', JSON.stringify(password));
				localStorage.setItem('passwordDate', JSON.stringify(getDateNow()));
				localStorage.setItem('LoginData', JSON.stringify(bb.data));
				localStorage.setItem('key', JSON.stringify(bb.data.user.key));
				localStorage.setItem('realName', JSON.stringify(bb.data.user.realName));
				window.location.href = "首页.html";
				// shouye();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　dismissDialog();　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

//首页数据
/*function shouye() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	$.ajax({
		type: "POST",
		url: url_prefix + "main",
		dataType: 'JSON',
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			var str11 = decryptByDESModeEBC(data["result"]); //解密
			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('homePageData', JSON.stringify(bb.data));
				window.location.href = "首页.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}*/
//获得当天时间
function getDateNow() {
	var date = new Date();
	var seperator1 = "-";
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var strDate = date.getDate();
	if (month >= 1 && month <= 9) {
		month = "0" + month;
	}
	if (strDate >= 0 && strDate <= 9) {
		strDate = "0" + strDate;
	}
	var currentdate = year + seperator1 + month + seperator1 + strDate;
	return currentdate;
}
//发情管理
function Oestrus() {
	omenOfOestrus();
}
//掉落管理
function Mating() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.isDispose = 0;
	map.page = 1;
	map.size = 20;
	map.phoneType = "android";
	map.language = "zh";
	map.ResonType=1;
	var jsonStr = JSON.stringify(map);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "cowAlarmList",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				var dropData=bb.data;
				localStorage.setItem('dropData', JSON.stringify(dropData));
				window.location = "掉落管理.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();
				mui.alert("网络请求超时...");
			}
		}
	});
	
}
//孕检管理
function Pregnancy() {
	mui.alert("敬请期待。。。");
}
//统计发情列表
function tjOestrus() {
	var  map={}
	map.name=JSON.parse(localStorage.getItem('paramsNameDate'));
	localStorage.setItem('DetailsType', JSON.stringify(11));
	DetailsOfOestrus(map);

	//统计二天疑似发情情况
}

//统计配种列表
function tjMating() {
	var  map={}
	map.name=JSON.parse(localStorage.getItem('paramsNameDate'));
	localStorage.setItem('DetailsType', JSON.stringify(12));
	DetailsOfOestrus(map);
}
//统计孕检列表
function tjPregnancy() {
	var  map={}
	map.name=JSON.parse(localStorage.getItem('paramsNameDate'));
	localStorage.setItem('DetailsType', JSON.stringify(13));
	DetailsOfOestrus(map);
}
//统计待配
function tjMatched() {
	var  map={}
	map.name=JSON.parse(localStorage.getItem('paramsNameDate'));
	localStorage.setItem('DetailsType', JSON.stringify(14));
	DetailsOfOestrus(map);
}
// 健康预警
function HealthWarn() {
	var  map={}
	map.name=JSON.parse(localStorage.getItem('paramsNameDate'));
	localStorage.setItem('DetailsType', JSON.stringify(15));
	DetailsOfOestrus(map);
}
//统计异常列表
function tjabnormal() {
	window.location = "统计详情.html";
}
//牛只管理界面选择牛舍接口
function Cattle() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	showDialog()
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "houseList",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str11 = decryptByDESModeEBC(data["result"]); //解密
			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				var ChooseACowshedArr = new Array();
				var Arr1 = {
					"value": null,
					"text": "全部牛舍"
				};
				ChooseACowshedArr.push(Arr1);
				var j = 0;
				for(var i = 0; i < bb.data.length; i++) {
					if(bb.data[i]["houseType"] == "1"){
					    var Arr = {
                            "value": "",
                            "text": ""
                        };
                        ChooseACowshedArr.push(Arr);
                        ChooseACowshedArr[j + 1]["value"] = bb.data[i]["houseID"];
                        ChooseACowshedArr[j + 1]["text"] = bb.data[i]["houseName"];
                        j++;
					}
				}
				var outEnterCowshed = JSON.parse(localStorage.getItem('outEnterCowshed'));
				(function($, doc) {
					$.init();
					$.ready(function() {
						var _getParam = function(obj, param) {
							return obj[param] || '';
						};
						//普通示例
						var userPicker = new $.PopPicker();
						userPicker.setData(ChooseACowshedArr);
						userPicker.show(function(items) {
                        localStorage.setItem('ChooseACowshedData', JSON.stringify(JSON.stringify(items[0]["value"])));
                        showDialog();
						if (items[0]["value"] == null) {
							Cattle1()
						} else{
							cluster();
						}
						console.log(items[0]["value"])
                        
                        })
					});
				})(mui, document);
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//牛只管理
function Cattle1() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var ChooseACowshedData = JSON.parse(localStorage.getItem('ChooseACowshedData'));
	console.log(ChooseACowshedData)
	var str = JSON.parse(localStorage.getItem('nainiuCode'));
	var map = {};
	if(str != 1) {
		if(ChooseACowshedData == "null") {
			map.houseID = '';
		} else {
			map.houseID = ChooseACowshedData;
		}
	}
	map.key = keys;
	map.page = 1;
	map.size = 20;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "cowManagement",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			localStorage.setItem('nainiuCode', JSON.stringify(0));
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			dismissDialog();
			if(bb.head.status == 1) {
				localStorage.setItem('CattleData', JSON.stringify(bb.data));
				console.log(bb.data);
				localStorage.setItem('CattleSeachData', JSON.stringify(''));
				window.location = "2.1牛只列表.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			localStorage.setItem('nainiuCode', JSON.stringify(0));　
			if(status == 'timeout') { //超时,status还有success,error等值的情况　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//根据牛舍查询分群
function cluster(){
    var keys = JSON.parse(localStorage.getItem('key'));
	var ChooseACowshedData = JSON.parse(localStorage.getItem('ChooseACowshedData'));
	var str = JSON.parse(localStorage.getItem('nainiuCode'));
	var map = {};
	if(str != 1) {
		if(ChooseACowshedData == "null") {
			map.houseID = '';
		} else {
			map.houseID = ChooseACowshedData;
		}
	}
    map.key = keys;
    map.page = 1;
    map.size = 20;
    map.phoneType = "android";
    map.language = "zh";
    var jsonStr = JSON.stringify(map);
    var ajaxTimeoutTest = $.ajax({
        type: "POST",
        url: url_prefix + "houseListByCluster",
        dataType: 'JSON',
        timeout: 10000,
        data: {
            'request': encryptByDES(jsonStr)
        },
        success: function(data) {
            var clusterStr11 = decryptByDESModeEBC(data["result"]); //解密
            var clusterParams = clusterStr11.replace(/\+/g, " "); //去掉字符串里的+号
            var clusterStr12 = UTFTranslate.ReChange(chineseFromUtf8Url(clusterParams)); //转utf8
            var clusterDatas = JSON.stringify(clusterStr12); //转JSON字符串
            var clusterAa1 = clusterDatas.replace(/\\n/g, " "); //去掉换行
            var clusterObjs = eval('(' + clusterAa1 + ')');
            var clusterBb = eval('(' + clusterObjs + ')');
            dismissDialog();
            if(clusterBb.head.status == 1) {
                console.log(clusterBb);
                if(clusterBb.data.length != 0){
                    var ChooseACowshedArr = new Array();
                    for(var i = 0; i < clusterBb.data.length; i++) {
                        var clusterArr = {
                            "value": "",
                            "text": ""
                        };
                        ChooseACowshedArr.push(clusterArr);
                        ChooseACowshedArr[i]["value"] = clusterBb.data[i]["houseID"];
                        ChooseACowshedArr[i]["text"] = clusterBb.data[i]["houseName"];
                    }
                    (function($, doc) {
                        $.init();
                        $.ready(function() {
                            var _getParam = function(obj, param) {
                                return obj[param] || '';
                            };
                            var userPicker = new $.PopPicker();
                            userPicker.setData(ChooseACowshedArr);
                            userPicker.show(function(items) {
                                localStorage.setItem('ChooseACowshedData', JSON.stringify(JSON.stringify(items[0]["value"])));
                                showDialog();
                                Cattle1();
                            });
                        })
                    })(mui, document);
                }else{
                  mui.alert("该牛舍暂无分群");
                }
            } else {
                mui.alert(clusterBb.head.info);
            }
        },
        complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
            if(status == 'timeout') { //超时,status还有success,error等值的情况　　　　　
                ajaxTimeoutTest.abort();　　　　　
                mui.alert("网络请求超时...");　　　　
            }　　
        }
    });
}
//牛只管理搜索
function CattleSeach() {
	var CattleSeach = $("#CattleSeachData").val();
	console.log(CattleSeach)
	if(CattleSeach == '') {
		mui.toast("请输入您的搜索内容");
	} 
		localStorage.setItem('CattleSeachData', JSON.stringify(CattleSeach));
		var ChooseACowshedData = JSON.parse(localStorage.getItem('ChooseACowshedData'));
		var keys = JSON.parse(localStorage.getItem('key'));
		var str = JSON.parse(localStorage.getItem('nainiuCode'));
		var map = {};

		if(ChooseACowshedData == "null") {
			map.houseID = '';
		} else {
			map.houseID = ChooseACowshedData;
		}

		map.key = keys;
		map.page = 1;
		map.size = 20;
		map.searchKey = CattleSeach;
		map.phoneType = "android";
		map.language = "zh";
		var jsonStr = JSON.stringify(map);
		var ajaxTimeoutTest = $.ajax({
			type: "POST",
			url: url_prefix + "cowManagement",
			dataType: 'JSON',
			timeout: 10000,
			data: {
				'request': encryptByDES(jsonStr)
			},
			success: function(data) {
				var str1 = decryptByDESModeEBC(data["result"]); //解密
				var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
				var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
				var datas = JSON.stringify(str2); //转JSON字符串
				var aa = datas.replace(/\\n/g, " "); //去掉换行
				var objs = eval('(' + aa + ')');
				var bb = eval('(' + objs + ')');
				if(bb.head.status == 1) {
					localStorage.setItem('CattleData', JSON.stringify(bb.data));
					console.log(bb.data);
					window.location = "2.1牛只列表.html";
				} else {
					mui.alert(bb.head.info);
				}
			},
			complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
				　　　　
				dismissDialog();
				if(status == 'timeout') { //超时,status还有success,error等值的情况
					　　　　　
					ajaxTimeoutTest.abort();　　　　　
					mui.alert("网络请求超时...");　　　　
				}　　
			}
		});
	
}
//牛只修改跳转
function modifyView() {
	localStorage.setItem('CowtianjiaNumber', JSON.stringify(2));
	cowVarietyInterface();
}

function ts() {

}
//牛只修改数据
function cowModify() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var deliveryDate = $("#deliveryDate").val();
	var Last_mating = $("#Last_mating").val();
	var parity = $("#parity").val();
	var reproductive_status = $("#reproductive_status").val();
//	alert(deliveryDate);
	var cowCode = $("#cowCode").html();
	var birthday = $("#birthday").val();
	var houseName = $("#noApplicationRecord").html();
	var equipmentDetails = JSON.parse(localStorage.getItem('equipmentDetails'));
	var houseID = equipmentDetails.houseID;

	var deviceCode = $("#deviceSN").val();
	var modifyDeviceSN = JSON.parse(localStorage.getItem('modifyDeviceSN'));
	console.log(modifyDeviceSN);
	if(modifyDeviceSN == '' || modifyDeviceSN == null) {
		var deviceID = equipmentDetails.deviceID;
		var deviceSN = equipmentDetails.deviceSN;
	} else {
		var deviceID = modifyDeviceSN.deviceID;
		var deviceSN = equipmentDetails.deviceSN;
	}

	var statuss = $("#statuss").val();
	var cowStatus = JSON.parse(localStorage.getItem('cowStatus'));

	for(var i = 0; i < cowStatus.length; i++) {
		if(cowStatus[i].status.indexOf(statuss) != -1) {
			var statusID = cowStatus[i].statusID;
			console.log(statusID);
		}
	}
	var cowTypes = $("#cowTypes").val();
	var cowType = JSON.parse(localStorage.getItem('cowType'));
	for(var i = 0; i < cowType.length; i++) {
		if(cowType[i].cowType.indexOf(cowTypes) != -1) {
			var cowTypeID = cowType[i].cowTypeID;
			console.log(cowTypeID);
		}
	}
	var cowID = equipmentDetails.cowID;

	var overbiStr1 = $("#overbiStr1").val();
	var overbiStr2 = $("#overbiStr2").val();
	var cowConceive = $("#cowConceiveData").val();
	var cowVariety = $("#cowVarietyData").val();
	var physiology = $("#cowPhysiologyID").val();
	var conceiveID;
	var varietyID;
	var physiologyID;

	var cowConceiveArr = JSON.parse(localStorage.getItem('cowConceiveArr'));
	var cowVarietyArr = JSON.parse(localStorage.getItem('cowVarietyArr'));
	var cowPhysiology = JSON.parse(localStorage.getItem('cowPhysiology'));
	for(var i = 0; i < cowConceiveArr.length; i++) {
		if(cowConceive == cowConceiveArr[i]["cowConceive"]) {
			conceiveID = cowConceiveArr[i]["cowConceiveID"];
		}
	}
	for(var i = 0; i < cowVarietyArr.length; i++) {
		if(cowVariety == cowVarietyArr[i]["cowVariety"]) {
			varietyID = cowVarietyArr[i]["cowVarietyID"];
		}
	}
	for(var i = 0; i < cowPhysiology.length; i++) {
		if(physiology == cowPhysiology[i]["cowPhysiology"]) {
			physiologyID = cowPhysiology[i]["cowPhysiologyID"];
		}
	}

	if(birthday == null || birthday == '') {
		mui.toast("请选择出生日期")
		return;
	} else if(deviceCode == null || deviceCode == '') {
		mui.toast("请选择设备编号");
		return;
	}

	
	
	var map = {};
	if(physiology == equipmentDetails.physiology){
		map.isEditPhysiology = 0;
	}else{
		map.isEditPhysiology = 1;
	}
	map.key = keys;
	map.physiology = physiology;
	map.physiologyID = physiologyID;
	map.cowCode = cowCode;
	map.birthday = birthday;
	map.houseID = houseID;
	map.houseName = houseName;
	map.deviceSN = deviceSN;
	map.deviceCode = deviceCode;
	map.deviceID = deviceID;
	map.statusID = statusID;
	map.status = statuss;
	map.cowTypeID = cowTypeID;
	map.cowType = cowTypes;
	map.cowID = cowID;
	map.overbit1 = overbiStr1;
	map.overbit2 = overbiStr2;
	map.conceive = cowConceive;
	map.variety = cowVariety;
	map.conceiveID = conceiveID;
	map.varietyID = varietyID;
	map.phoneType = "android";
	map.language = "zh";
	map.deliveryDate=deliveryDate;
	map.Last_mating=Last_mating;
	map.parity=parity;
	map.reproductive_status=reproductive_status;
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "cowSave",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			localStorage.setItem('Cattlemodify', JSON.stringify(0));
			var str11 = decryptByDESModeEBC(data["result"]); //解密

			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('CowSubmission', JSON.stringify(bb.data));
				Cattle1();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}

	});
}
//牛舍管理
function Cowshed() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	var ToChangeIntoNumber = JSON.parse(localStorage.getItem('ToChangeIntoNumber'));
	if(ToChangeIntoNumber == 10) {
		var TurnOutDetails = JSON.parse(localStorage.getItem('TurnOutDetails'));
		map.key = keys;
		map.houseID = TurnOutDetails.houseID;
		map.phoneType = "android";
		map.language = "zh";
	} else {
		map.key = keys;
		map.phoneType = "android";
		map.language = "zh";
	}
	var jsonStr = JSON.stringify(map);
	showDialog()
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "houseList",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			 dismissDialog();
			var str11 = decryptByDESModeEBC(data["result"]); //解密
			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('CowtianjiaData', JSON.stringify(bb.data));
				window.location = "牛舍管理.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//牛舍搜索
function houseListSeach() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var CattleSeach = $("#CattleSeachDatacowLost").val();
	var map = {};
	var ToChangeIntoNumber = JSON.parse(localStorage.getItem('ToChangeIntoNumber'));
	if(ToChangeIntoNumber == 10) {
		var TurnOutDetails = JSON.parse(localStorage.getItem('TurnOutDetails'));
		map.key = keys;
		map.houseID = TurnOutDetails.houseID;
		map.phoneType = "android";
		map.language = "zh";
	} else {
		map.key = keys;
		map.phoneType = "android";
		map.language = "zh";
	}
	map.searchName = CattleSeach;
	var jsonStr = JSON.stringify(map);
	console.log(map)
	showDialog()
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "houseList",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			 dismissDialog();
			var str11 = decryptByDESModeEBC(data["result"]); //解密
			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('CowtianjiaData', JSON.stringify(bb.data));
				window.location = "牛舍管理.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
// 进入添加牛舍页面
function addCowshedView() {
	localStorage.setItem('CowtianjiaNumber', JSON.stringify(3));
	cowType();

}

function tt() {

}
//选择IP
function Obtainequipment(id) {
	var CowNumber = JSON.parse(localStorage.getItem('CowNumber'));
	var CowshedNumber = JSON.parse(localStorage.getItem('CowshedNumber'));
	var CattleNumber = JSON.parse(localStorage.getItem('CattleNumber'));
	var Cattlemodify = JSON.parse(localStorage.getItem('Cattlemodify'));
	if(CowNumber == 10) {
		var equipmentData = JSON.parse(localStorage.getItem('equipmentData'));
		localStorage.setItem('Cowreader', JSON.stringify(equipmentData[id]))
		console.log(equipmentData[id].deviceSN);
		window.location = "添加牛舍管理.html";
	} else if(CowshedNumber == 10) {
		var equipmentData = JSON.parse(localStorage.getItem('equipmentData'));
		localStorage.setItem('CowshedDeviceSN', JSON.stringify(equipmentData[id]))
		window.location = "修改牛舍信息.html";
	} else if(CattleNumber == 100) {
		var equipmentData = JSON.parse(localStorage.getItem('equipmentData'));
		localStorage.setItem('CattleDeviceSN', JSON.stringify(equipmentData[id]))
		console.log(equipmentData[id]);
		window.location = "2.4添加牛只.html";
	} else if(Cattlemodify == 100) {
		var equipmentData = JSON.parse(localStorage.getItem('equipmentData'));
		localStorage.setItem('modifyDeviceSN', JSON.stringify(equipmentData[id]))
		window.location = "修改牛只信息.html";
	} else {
		var equipmentData = JSON.parse(localStorage.getItem('equipmentData'));
		localStorage.setItem('shebeiDeviceSN', JSON.stringify(equipmentData[id]))
		//console.log(equipmentData[id]);
		addequipmentBut();
	}
}

//添加牛舍
function addCowshed() {
	if(undefined == document.getElementById("CowName").value || '' == document.getElementById("CowName").value) {
		mui.alert("请输入牛舍名称");
		return;
	}
	if(undefined == document.getElementById("houseCode").value || '' == document.getElementById("houseCode").value) {
		mui.alert("请输入牛舍编号");
		return;
	}
	if(null == document.getElementById("CowSize").value || '' == document.getElementById("CowSize").value) {
		mui.alert("请输入牛舍容量");
		return;
	}
	if(null == document.getElementById("CowPosition").value || '' == document.getElementById("CowPosition").value) {
		mui.alert("请输入牛舍位置");
		return;
	}
	if(null == document.getElementById("CowPosi").value || '' == document.getElementById("CowPosi").value) {
		mui.alert("请选择阅读器");
		return;
	}
	var keys = JSON.parse(localStorage.getItem('key'));
	var capacity = $("#CowSize").val();
	var name = $("#CowName").val();
	var address = $("#CowPosition").val();
	var houseCode = $("#houseCode").val();
	var Cowreader = JSON.parse(localStorage.getItem('Cowreader'));
	var noApplicationRecord = Cowreader.deviceID;
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "saveHouse",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES("{\"key\":\"" + keys + "\",\"capacity\":\"" + capacity + "\",\"houseCode\":\"" + houseCode + "\",\"name\":\"" + name + "\",\"address\":\"" + address + "\",\"deviceID\":\"" + noApplicationRecord + "\",\"page\":\"1\",\"phoneType\":\"android\",\"language\":\"zh\"}")
		},
		success: function(data) {
			dismissDialog();
			localStorage.setItem('CowNumber', JSON.stringify(0));
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				Cowshed();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

//设备管理
function equipments() {
	var scope;
	var useID;
	var useType;
	var statusID;
	var CowNumber = JSON.parse(localStorage.getItem('CowNumber'));
	var CattleNumber = JSON.parse(localStorage.getItem('CattleNumber'));
	var Cattlemodify = JSON.parse(localStorage.getItem('Cattlemodify'));
	var CowshedNumber = JSON.parse(localStorage.getItem('CowshedNumber'));
	if(CowNumber == 10) {
		scope = "2";
		useID = null;
		useType = "0";
		statusID = "0";
	} else if(CowshedNumber == 10) {
		var CowshedDeviceSN = JSON.parse(localStorage.getItem('modifyCowshed'));
		var str = CowshedDeviceSN.houseID;
		scope = "2";
		useID = str;
		useType = "0";
		statusID = "0";
	} else if(CattleNumber == 100) {
		scope = "1";
		useID = null;
		useType = "0";
		statusID = "0";
	} else if(Cattlemodify == 100) {
		var useIDStr = JSON.parse(localStorage.getItem('useID'));
		scope = "1";
		useID = useIDStr;
		useType = "0";
		statusID = "0";
	} else {
		scope = "0";
		useID = null;
		useType = "2";
		statusID = "1";
	}
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.page = "1";
	map.scope = scope;
	map.useID = useID;
	map.statusID = statusID;
	map.useType = useType;
	map.size = "20";
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	showDialog() 
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "deviceManagement",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('equipmentData', JSON.stringify(bb.data));
				localStorage.setItem('equipmentSeachData', JSON.stringify('请输入搜索内容'));
				window.location = "设备管理.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

function addReturn() {
	equipments();
}

function Returnfunction() {
	var CowNumber = JSON.parse(localStorage.getItem('CowNumber'));
	var CowshedNumber = JSON.parse(localStorage.getItem('CowshedNumber'));
	var CattleNumber = JSON.parse(localStorage.getItem('CattleNumber'));
	var Cattlemodify = JSON.parse(localStorage.getItem('Cattlemodify'));
	if(CowNumber == 10) {
		localStorage.setItem('Cowreader', JSON.stringify(''))
		window.location = "添加牛舍管理.html";
	} else if(CowshedNumber == 10) {
		localStorage.setItem('CowshedDeviceSN', JSON.stringify(''))
		window.location = "修改牛舍信息.html";
	} else if(CattleNumber == 100) {
		localStorage.setItem('CattleDeviceSN', JSON.stringify(''))
		window.location = "2.4添加牛只.html";
	} else if(Cattlemodify == 100) {
		localStorage.setItem('modifyDeviceSN', JSON.stringify(''))
		window.location = "修改牛只信息.html";
	} else {
		localStorage.setItem('shebeiDeviceSN', JSON.stringify(''))
		window.location = "功能列表.html";
	}

}
//设备管理搜索
function equipmentSeach() {
	var equipmentSeach = $("#equipmentData").val();
	console.log(equipmentSeach);
	if(equipmentSeach.indexOf("请输入搜索内容") != -1) {
		mui.toast("请输入您的搜索内容");
		equipments();
	} else {
		localStorage.setItem('equipmentSeachData', JSON.stringify(equipmentSeach));
		var scope;
		var CowNumber = JSON.parse(localStorage.getItem('CowNumber'));
		var CattleNumber = JSON.parse(localStorage.getItem('CattleNumber'));
		var Cattlemodify = JSON.parse(localStorage.getItem('Cattlemodify'));
		var CowshedNumber = JSON.parse(localStorage.getItem('CowshedNumber'));
		if(CowNumber == 10) {
			scope = "2";
			useID = null;
			useType = "0";
			statusID = "0";
		} else if(CowshedNumber == 10) {
			var CowshedDeviceSN = JSON.parse(localStorage.getItem('CowshedDeviceSN'));
			var str //= CowshedDeviceSN.houseID;
			console.log(CowshedDeviceSN);
			scope = "2";
			useID = str;
			useType = "0";
			statusID = "0";
		} else if(CattleNumber == 100) {
			scope = "1";
			useID = null;
			useType = "0";
			statusID = "0";
		} else if(Cattlemodify == 100) {
			var useIDStr = JSON.parse(localStorage.getItem('useID'));
			scope = "1";
			useID = useIDStr;
			useType = "0";
			statusID = "0";
		} else {
			scope = "0";
			useID = null;
			useType = "2";
			statusID = "1";
		}
		var keys = JSON.parse(localStorage.getItem('key'));
		var map = {};
		map.key = keys;
		map.page = "1";
		map.scope = scope;
		map.useID = useID;
		map.statusID = statusID;
		map.useType = useType;
		map.size = "30";
		map.searchKey = equipmentSeach;
		map.phoneType = "android";
		map.language = "zh";
		var jsonStr = JSON.stringify(map);
		console.log(jsonStr);

		var ajaxTimeoutTest = $.ajax({
			type: "POST",
			url: url_prefix + "deviceManagement",
			dataType: 'JSON',
			timeout: 10000,
			data: {
				'request': encryptByDES(jsonStr)
			},
			success: function(data) {
				var str1 = decryptByDESModeEBC(data["result"]); //解密
				var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
				var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
				var datas = JSON.stringify(str2); //转JSON字符串
				var aa = datas.replace(/\\n/g, " "); //去掉换行
				var objs = eval('(' + aa + ')');
				var bb = eval('(' + objs + ')');
				if(bb.head.status == 1) {
					localStorage.setItem('equipmentData', JSON.stringify(bb.data));
					window.location = "设备管理.html";
				} else {
					mui.alert(bb.head.info);
				}
			},
			complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
				　　　
				dismissDialog();　
				if(status == 'timeout') { //超时,status还有success,error等值的情况
					　　　　　
					ajaxTimeoutTest.abort();　　　　　
					mui.alert("网络请求超时...");　　　　
				}　　
			}
		});
	}
}
//添加设备 -获取设备类型
function addequipment() {
	var keys = JSON.parse(localStorage.getItem('key'));
	$.ajax({
		type: "POST",
		url: url_prefix + "deviceType",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES("{\"key\":\"" + keys + "\",\"phoneType\":\"android\",\"language\":\"zh\"}")
		},
		success: function(data) {
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('deviceTypeData', JSON.stringify(bb.data));
				deviceStatus();
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}
//添加设备 - 获取设备状态接口
function deviceStatus() {
	var keys = JSON.parse(localStorage.getItem('key'));
	$.ajax({
		type: "POST",
		url: url_prefix + "deviceStatus",
		timeout: 10000,
		dataType: 'JSON',
		data: {
			'request': encryptByDES("{\"key\":\"" + keys + "\",\"phoneType\":\"android\",\"language\":\"zh\"}")
		},
		success: function(data) {
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('deviceStatusData', JSON.stringify(bb.data));
				window.location = "添加设备管理.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}

function addequipmentBut() {
	var keys = JSON.parse(localStorage.getItem('key'));
	$.ajax({
		type: "POST",
		url: url_prefix + "deviceType",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES("{\"key\":\"" + keys + "\",\"phoneType\":\"android\",\"language\":\"zh\"}")
		},
		success: function(data) {
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('deviceTypeData', JSON.stringify(bb.data));
				deviceStatusBut();
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}
//添加设备 - 获取设备状态接口
function deviceStatusBut() {
	var keys = JSON.parse(localStorage.getItem('key'));
	$.ajax({
		type: "POST",
		url: url_prefix + "deviceStatus",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES("{\"key\":\"" + keys + "\",\"phoneType\":\"android\",\"language\":\"zh\"}")
		},
		success: function(data) {
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('deviceStatusData', JSON.stringify(bb.data));
				window.location = "修改设备信息.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}

//转舍
function TransferHouse() {
	window.location = "4.转舍1.html";
}
//异常管理
function abnormal() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	$.ajax({
		type: "POST",
		url: url_prefix + "cowLost",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {

			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowLostData', JSON.stringify(bb.data));
				window.location = "批量找牛-列表.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});

}
//找牛搜索
function cowLostSeach() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.searchName = $("#CattleSeachDatacowLost").val();
	if($("#CattleSeachDatacowLost").val() == ''){
		mui.toast('请输入您的搜索内容')
	}
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	$.ajax({
		type: "POST",
		url: url_prefix + "cowLost",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {

			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowLostData', JSON.stringify(bb.data));
				window.location = "批量找牛-列表.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});

}
//牛舍搜索
function CowshedButID() {
				var houseID = JSON.parse(localStorage.getItem('alarmID'));
				var keys = JSON.parse(localStorage.getItem('key'));
				var map = {};
				map.key = keys;
				map.searchName = $("#CattleSeachDataCowshed").val();
				if($("#CattleSeachDataCowshed").val() == ''){
					mui.toast('请输入您的搜索内容')
				}
				map.houseID = houseID;
				map.phoneType = "android";
				map.language = "zh";
				console.log(map)
				var jsonStr = JSON.stringify(map);
				$.ajax({
					type: "POST",
					url: url_prefix + "alarm",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						var str1 = decryptByDESModeEBC(data["result"]); //解密
						var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
						var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str2); //转JSON字符串
						var aa = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							console.log(bb.data);
							localStorage.setItem('alarmData', JSON.stringify(bb.data));
							window.location = "5.预警管理.html";
						} else {
							mui.alert(bb.head.info);
						}
					}
				});
			
			}
//首页按钮
function homePage() {
	window.location = "首页.html";
}
//功能列表
function FunctionList() {
	localStorage.setItem('CowNumber', JSON.stringify(1));
	localStorage.setItem('Cattlemodify', JSON.stringify(0));
	localStorage.setItem('CattleNumber', JSON.stringify(0));
	localStorage.setItem('outEnterCowshed', JSON.stringify(0));
	window.location = "功能列表.html";
}
//统计分析
function statisticalAnalysis() {
	var keys = JSON.parse(localStorage.getItem('key'));
	$.ajax({
		type: "POST",
		url: url_prefix + "statistics",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES("{\"key\":\"" + keys + "\",\"phoneType\":\"android\",\"language\":\"zh\"}")
		},
		success: function(data) {
			var str11 = decryptByDESModeEBC(data["result"]); //解密
			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('statisticalAnalysisData', JSON.stringify(bb.data));
				window.location = "统计详情.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}
// 个人中心
function PersonalCenter() {
	window.location = "个人中心.html";
}

// 牧场定位
function position() {
	var keys = JSON.parse(localStorage.getItem('key'));
	$.ajax({
		type: "POST",
		url: url_prefix + "orientation",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES("{\"key\":\"" + keys + "\",\"phoneType\":\"android\",\"language\":\"zh\"}")
		},
		success: function(data) {
			var str11 = decryptByDESModeEBC(data["result"]); //解密
			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			console.log('2', bb)
			if(bb.head.status == 1) {
				localStorage.setItem('postionData', JSON.stringify(bb.data));
				console.log('1', bb.data)
				window.location = "牧场定位.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
	// window.location = "牧场定位.html";
}

function CattleReturn() {
	window.location = "功能列表.html";
}
//添加牛只
function Cowtianjia() {
	localStorage.setItem('CowtianjiaNumber', JSON.stringify(1));
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "houseList",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			var str11 = decryptByDESModeEBC(data["result"]); //解密
			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('CowtianjiaData', JSON.stringify(bb.data));
				//cowVarietyInterface();
				cowPhysiology()
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　
			dismissDialog();　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//奶牛类型接口
function cowType() {

	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	$.ajax({
		type: "POST",
		url: url_prefix + "cowType",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowType', JSON.stringify(bb.data));
				
				cowPhysiology()
			} else {
				mui.alert(bb.head.info);
			}
		}
	});

}
//奶牛状态接口
function cowStatus() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	$.ajax({
		type: "POST",
		url: url_prefix + "cowStatus",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowStatus', JSON.stringify(bb.data));
				var numbers = JSON.parse(localStorage.getItem('CowtianjiaNumber'));
				if(numbers == 1) {
					window.location = "2.4添加牛只.html";
				} else if(numbers == 2) {
					window.location = "修改牛只信息.html";
				} else if(numbers == 3) {
					window.location = "添加牛舍管理.html";
				}
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}
//提交添加牛只数据
function CowSubmission() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var cowCode = $("#cowCode").val();
	var birthday = $("#birthday").val();
	var deliveryDate = $("#deliveryDate").val();
	var Last_mating = $("#Last_mating").val();
	var reproductive_status = $("#reproductive_status").val();
	var houseName = $("#noApplicationRecord").val();
	var CowtianjiaData = JSON.parse(localStorage.getItem('CowtianjiaData'));
	for(var i = 0; i < CowtianjiaData.length; i++) {
		if(CowtianjiaData[i].houseName.indexOf(houseName) != -1) {
			var houseID = CowtianjiaData[i].houseID;
			console.log(houseID);
		}
	}
	var deviceCode = $("#deviceSN").html();

	if(birthday == null || birthday == '') {
		mui.toast("请选择出生日期")
		return;
	} else if(deviceCode == null || deviceCode == '') {
		mui.toast("请选择设备编号");
		return;
	}
	var CattleDeviceSN = JSON.parse(localStorage.getItem('CattleDeviceSN'));
	var deviceID = CattleDeviceSN.deviceID;
	var deviceSN = CattleDeviceSN.deviceSN;

	var statuss = $("#statuss").val();
	var cowStatus = JSON.parse(localStorage.getItem('cowStatus'));
	for(var i = 0; i < cowStatus.length; i++) {
		if(cowStatus[i].status.indexOf(statuss) != -1) {
			var statusID = cowStatus[i].statusID;
			console.log(statusID);
		}
	}
	var cowTypes = $("#cowTypes").val();
	var cowType = JSON.parse(localStorage.getItem('cowType'));
	for(var i = 0; i < cowType.length; i++) {
		if(cowType[i].cowType.indexOf(cowTypes) != -1) {
			var cowTypeID = cowType[i].cowTypeID;
			console.log(cowTypeID);
		}
	}
	var overbiStr1 = $("#overbiStr1").val();
	var overbiStr2 = $("#overbiStr2").val();
	var cowConceive = $("#cowConceiveData").val();
	var cowVariety = $("#cowVarietyData").val();
	var physiology = $("#cowPhysiologyID").val();
	var conceiveID;
	var varietyID;
	var physiologyID;

	var cowConceiveArr = JSON.parse(localStorage.getItem('cowConceiveArr'));
	var cowVarietyArr = JSON.parse(localStorage.getItem('cowVarietyArr'));
	var cowPhysiology = JSON.parse(localStorage.getItem('cowPhysiology'));
	for(var i = 0; i < cowConceiveArr.length; i++) {
		if(cowConceive == cowConceiveArr[i]["cowConceive"]) {
			conceiveID = cowConceiveArr[i]["cowConceiveID"];
		}
	}
	for(var i = 0; i < cowVarietyArr.length; i++) {
		if(cowVariety == cowVarietyArr[i]["cowVariety"]) {
			varietyID = cowVarietyArr[i]["cowVarietyID"];
		}
	}
	for(var i = 0; i < cowPhysiology.length; i++) {
		if(physiology == cowPhysiology[i]["cowPhysiology"]) {
			physiologyID = cowPhysiology[i]["cowPhysiologyID"];
		}
	}

	var map = {};
	map.key = keys;
	map.isEditPhysiology = 0;
	map.physiology = physiology;
	map.physiologyID = physiologyID;
	map.cowCode = cowCode;
	map.birthday = birthday;
	map.houseID = houseID;
	map.houseName = houseName;
	map.deviceSN = deviceSN;
	map.deviceCode = deviceCode;
	map.deviceID = deviceID;
	map.statusID = statusID;
	map.status = statuss;
	map.cowTypeID = cowTypeID;
	map.cowType = cowTypes;
	map.overbit1 = overbiStr1;
	map.overbit2 = overbiStr2;
	map.conceive = cowConceive;
	map.variety = cowVariety;
	map.conceiveID = conceiveID;
	map.varietyID = varietyID;
	map.phoneType = "android";
	map.language = "zh";
	map.deliveryDate=deliveryDate;
	map.Last_mating=Last_mating;
	map.reproductive_status=reproductive_status;
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "cowSave",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			localStorage.setItem('CattleNumber', JSON.stringify(0));
			var str11 = decryptByDESModeEBC(data["result"]); //解密

			var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
			var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str12); //转JSON字符串
			var aa1 = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa1 + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('CowSubmission', JSON.stringify(bb.data));
				Cattle1();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//转舍提交
function ChangeCow() {
	if("请选择" == $("#nainiuCode").html()) {
		mui.alert("请选择奶牛编号");
		return;
	}
	if('请选择' == $("#ToChangeInto").html()) {
		mui.alert("请选择转入牛舍");
		return;
	}
	console.log($("#ToChangeInto").html())
	//	alert($("#nainiuCode").html())
	var keys = JSON.parse(localStorage.getItem('key'));
	var TurnOutDetails = JSON.parse(localStorage.getItem('TurnOutDetails'));
	var ToChangeIntoDetails = JSON.parse(localStorage.getItem('ToChangeIntoDetails'));
	var cowID = new Array();
	cowID.push(TurnOutDetails.cowID);
	var fromHouseID = TurnOutDetails.houseID;
	var toHouseID = ToChangeIntoDetails.houseID;
	var toHouseName = ToChangeIntoDetails.houseName;
	var map = {};
	map.key = keys;
	map.cowID = cowID;
	map.fromHouseID = fromHouseID;
	map.toHouseID = toHouseID;
	map.toHouseName = toHouseName;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	$.ajax({
		type: "POST",
		url: url_prefix + "transfer",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('ToChangeIntoNumber', JSON.stringify(''));
				localStorage.setItem('TurnOutNumber', JSON.stringify(''));
				window.location = "功能列表.html";
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}

function modifyCowsh() {

	if(undefined == document.getElementById("CowName").value || '' == document.getElementById("CowName").value) {
		mui.alert("请输入牛舍名称");
		return;
	}
	if(undefined == document.getElementById("houseCode").value || '' == document.getElementById("houseCode").value) {
		mui.alert("请输入牛舍编号");
		return;
	}
	if(null == document.getElementById("CowSize").value || '' == document.getElementById("CowSize").value) {
		mui.alert("请输入牛舍容量");
		return;
	}
	if(null == document.getElementById("CowPosition").value || '' == document.getElementById("CowPosition").value) {
		mui.alert("请输入牛舍位置");
		return;
	}
	if(null == document.getElementById("CowPosi").value || '' == document.getElementById("CowPosi").value) {
		mui.alert("请选择阅读器");
		return;
	}
	var keys = JSON.parse(localStorage.getItem('key'));
	var capacity = $("#CowSize").val();
	var name = $("#CowName").val();
	var address = $("#CowPosition").val();
	var houseCode = $("#houseCode").val();
	var modifyCowshed = JSON.parse(localStorage.getItem('modifyCowshed'));
	console.log(modifyCowshed);
	var houseID = modifyCowshed.houseID;
	var CowshedNumber = JSON.parse(localStorage.getItem('CowshedNumber'));
	if(CowshedNumber == 10) {
		var CowshedDeviceSN = JSON.parse(localStorage.getItem('CowshedDeviceSN'));
		var noApplicationRecord = CowshedDeviceSN.deviceID;

	} else {
		var noApplicationRecord = modifyCowshed.deviceID;
	}
	var map = {};
	map.key = keys;
	map.houseID = houseID;
	map.capacity = capacity;
	map.name = name;
	map.houseCode = houseCode;
	map.address = address;
	map.deviceID = noApplicationRecord;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "saveHouse",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				Cowshed();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//发情揭发成功率需要删除
/*function emotionalSuccessRate() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "emotionalSuccessRate",
		dataType: 'JSON',
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('emotionalSuccessRate', JSON.stringify(bb.data));
				omenOfOestrus();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}*/
//发情征兆统计数据
function omenOfOestrus() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "estrusStatistics",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('OmenOfOestrus', JSON.stringify(bb.data));
				creepingSpanBehavior();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//爬跨行为统计数据
function creepingSpanBehavior() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "climbingStatistics",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('CreepingSpanBehavior', JSON.stringify(bb.data));
				abnormalActivityVolume();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//活动量异常统计数据
function abnormalActivityVolume() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "activityStatistics",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('AbnormalActivityVolume', JSON.stringify(bb.data));
				estrusExpose();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

function estrusExpose() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "estrusExpose",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('estrusExposeData', JSON.stringify(bb.data));
				window.location = "发情揭发.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//图形跳转页面
function DetailsOfOestrus(params) {
	var type = JSON.parse(localStorage.getItem('DetailsType'));
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.page = 1;
	map.size = 60;
	var birthdayDate = JSON.parse(localStorage.getItem('birthdayDate'));
	if(params == undefined) {
		var paramsName = JSON.parse(localStorage.getItem('paramsNameDate'))		
		map.startDate = paramsName;
		map.endDate = paramsName;
	} else if(params == "发情揭发成功率"){
		type = 4;
		map.startDate = birthdayDate;
		map.endDate = birthdayDate;
	}else if(params == "发情揭发比例"){
		type = 5;
		map.startDate = birthdayDate;
		map.endDate = birthdayDate;
	}else if(params == "健康预警"){
		type = 7;
		map.startDate = birthdayDate;
		map.endDate = birthdayDate;
	}else if(params == "发情漏检率"){
		type = 6;
		map.startDate = birthdayDate;
		map.endDate = birthdayDate;
	}else {		
		map.startDate = params.name;
		map.endDate = params.name;
	}
	localStorage.setItem('DetailsType',JSON.stringify(type));
	if(params != undefined){
		map.date=params.name;
	}
	map.type = type;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "estrusList",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb.data.length)
				// if (bb.data.length > 0) {
					localStorage.setItem('DetailsOfOestrusData', JSON.stringify(bb.data));
					if(type==14){
						window.location = "待配.html";
					}else{
						window.location = "跨爬行为详情.html";
					}
					
				// }else{
					// mui.alert("暂无数据...")
				// }
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

/*function deviceSubBut() {
	if(undefined == document.getElementById("deviceSN").value || '' == document.getElementById("deviceSN").value) {
		mui.alert("请输入设备序列号");
		return;
	}
	if($("#noApplicationRecord").html() == "智能项圈") {
		if(undefined == document.getElementById("equipment13").value || '' == document.getElementById("equipment13").value) {
			mui.alert("请输入设备RFID号");
			return;
		}
		if(null == document.getElementById("equipment14").value || '' == document.getElementById("equipment14").value) {
			mui.alert("请输入设备编号");
			return;
		}
	} else {
		if(undefined == document.getElementById("equipment11").value || '' == document.getElementById("equipment11").value) {
			mui.alert("请输入设备IP");
			return;
		}
		if(null == document.getElementById("equipment12").value || '' == document.getElementById("equipment12").value) {
			mui.alert("请输入设备端口号");
			return;
		}
	}
	var keys = JSON.parse(localStorage.getItem('key'));
	var deviceType = $("#noApplicationRecord").html();
	var deviceTypeData = JSON.parse(localStorage.getItem('deviceTypeData'));
	for(var i = 0; i < deviceTypeData.length; i++) {
		if(deviceTypeData[i].deviceType == deviceType) {
			var deviceTypeID = deviceTypeData[i].deviceTypeID;
			console.log(deviceTypeID);
		}
	}
	var deviceSN = $("#deviceSN").val();
	var status = $("#deviceStatusID").val();
	var deviceStatusData = JSON.parse(localStorage.getItem('deviceStatusData'));
	console.log(deviceStatusData);
	for(var i = 0; i < deviceStatusData.length; i++) {
		if(deviceStatusData[i].status == status) {
			var statusID = deviceStatusData[i].statusID;
			console.log(statusID);
		}
	}
	var shebeiDeviceSN = JSON.parse(localStorage.getItem('shebeiDeviceSN'));
	deviceID = shebeiDeviceSN.deviceID;
	var equipment11 = $("#equipment11").val();
	var equipment12 = $("#equipment12").val();
	var equipment13 = $("#equipment13").val();
	var equipment14 = $("#equipment14").val();
	console.log(equipment11);
	console.log(equipment12);
	var map = {};
	map.key = keys;
	map.rfid = equipment13;
	map.deviceCode = equipment14;
	map.port = equipment12;
	map.ip = equipment11;
	map.deviceTypeID = deviceTypeID;
	map.deviceType = deviceType;
	map.deviceSN = deviceSN;
	map.status = status;
	map.statusID = statusID;
	map.deviceID = deviceID;
	map.use = null;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "saveDevice",
		dataType: 'JSON',
		timeout: 1000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(data);
				localStorage.setItem('deviceStatusData', JSON.stringify(bb.data));
				equipments();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}*/
//发情详情页面搜索
function searchFindACow() {
	var paramsNameDate = JSON.parse(localStorage.getItem('paramsNameDate'));

	var searchKey = $("#searchData").val();
	var startDate = paramsNameDate;
	var endDate = paramsNameDate;

	var type = JSON.parse(localStorage.getItem('DetailsType'));
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.searchKey = searchKey;
	map.startDate = startDate;
	map.endDate = endDate;
	map.page = 1;
	map.size = 20;
	map.type = type;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);

	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "estrusList",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('DetailsOfOestrusData', JSON.stringify(bb.data));
				window.location = "跨爬行为详情.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

//奶牛品种接口
function cowVarietyInterface() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "cowVariety",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('cowVarietyArr', JSON.stringify(bb.data));
				cowConceiveInterface();
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

//奶牛怀孕史接口
function cowConceiveInterface() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	showDialog();
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "cowConceive",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				console.log(bb)
				localStorage.setItem('cowConceiveArr', JSON.stringify(bb.data));
				cowType();

			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			　　　　
			dismissDialog();
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

//奶牛生理状态接口
function cowPhysiology() {
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	var jsonStr = JSON.stringify(map);
	console.log(jsonStr);
	$.ajax({
		type: "POST",
		url: url_prefix + "cowPhysiology",
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowPhysiology', JSON.stringify(bb.data));
				cowStatus();
			} else {
				mui.alert(bb.head.info);
			}
		}
	});
}


var UTFTranslate = {
	Change: function(pValue) {
		return pValue.replace(/[^\u0000-\u00FF]/g, function($0) {
			return escape($0).replace(/(%u)(\w{4})/gi, "&#x$2;")
		});
	},
	ReChange: function(pValue) {
		return unescape(pValue.replace(/&#x/g, '%u').replace(/\\u/g, '%u').replace(/;/g, ''));
	}
};

function str2utf8(str) {
	encoder = new TextEncoder('utf8');
	return encoder.encode(str);
}

function encryptByDES(message) {

	//把私钥转换成16进制的字符串
	var keyHex = CryptoJS.enc.Utf8.parse('com.yinda.ifss');
	//	var messages = str2utf8(message);
	//	console.log(messages);
	//模式为ECB padding为Pkcs7
	messages = encodeURI(message);
	var encrypted = CryptoJS.DES.encrypt(messages, keyHex, {
		mode: CryptoJS.mode.ECB,
		padding: CryptoJS.pad.Pkcs7,
	});

	//加密出来是一个16进制的字符串
	return encrypted.ciphertext.toString();
}
//DES  ECB模式解密
function decryptByDESModeEBC(ciphertext) {
	//把私钥转换成16进制的字符串
	var keyHex = CryptoJS.enc.Utf8.parse('com.yinda.ifss');
	//把需要解密的数据从16进制字符串转换成字符byte数组
	var decrypted = CryptoJS.DES.decrypt({
		ciphertext: CryptoJS.enc.Hex.parse(ciphertext)
	}, keyHex, {
		mode: CryptoJS.mode.ECB,
		padding: CryptoJS.pad.Pkcs7
	});
	//以utf-8的形式输出解密过后内容
	var result_value = decrypted.toString(CryptoJS.enc.Utf8);
	return result_value;
}
//JOSN解码加转码
function strReplaceAll(str, oldStr, newStr) {
	var regS = new RegExp(oldStr, "gi");
	newStr = str.replace(regS, newStr);
	return newStr;
}

function chineseFromUtf8Url(strUtf8) {
	var bstr = "";
	var nOffset = 0; //   processing   point   on   strUtf8 

	if(strUtf8 == "")
		return "";
	//strUtf8 = strUtf8.toLowerCase();
	nOffset = strUtf8.indexOf("%e");
	if(nOffset == -1) {
		nOffset = strUtf8.indexOf("%E");
	}
	if(nOffset == -1) {
		return strUtf8;
	}

	while(nOffset != -1) {
		bstr += strUtf8.substr(0, nOffset);
		strUtf8 = strUtf8.substr(nOffset, strUtf8.length - nOffset);
		if(strUtf8 == "" || strUtf8.length < 9) { //   bad   string 
			return bstr;
		}
		bstr += utf8CodeToChineseChar(strUtf8.substr(0, 9).toLowerCase());
		strUtf8 = strUtf8.substr(9, strUtf8.length - 9);
		nOffset = strUtf8.indexOf("%e");
		if(nOffset == -1) {
			nOffset = strUtf8.indexOf("%E");
		}
	}
	return bstr + strUtf8;
}

function unicodeFromUtf8(strUtf8) {
	var bstr = "";
	var nTotalChars = strUtf8.length; //   total   chars   to   be   processed. 
	var nOffset = 0; //   processing   point   on   strUtf8 
	var nRemainingBytes = nTotalChars; //   how   many   bytes   left   to   be   converted 
	var nOutputPosition = 0;
	var iCode, iCode1, iCode2; //   the   value   of   the   unicode. 

	while(nOffset < nTotalChars) {
		iCode = strUtf8.charCodeAt(nOffset);
		if((iCode & 0x80) == 0) //   1   byte. 
		{
			if(nRemainingBytes < 1) //   not   enough   data 
				break;

			bstr += String.fromCharCode(iCode & 0x7F);
			nOffset++;
			nRemainingBytes -= 1;
		} else if((iCode & 0xE0) == 0xC0) //   2   bytes 
		{
			iCode1 = strUtf8.charCodeAt(nOffset + 1);
			if(nRemainingBytes < 2 || //   not   enough   data 
				(iCode1 & 0xC0) != 0x80) //   invalid   pattern 
			{
				break;
			}

			bstr += String.fromCharCode(((iCode & 0x3F) << 6) | (iCode1 & 0x3F));
			nOffset += 2;
			nRemainingBytes -= 2;
		} else if((iCode & 0xF0) == 0xE0) //   3   bytes 
		{
			iCode1 = strUtf8.charCodeAt(nOffset + 1);
			iCode2 = strUtf8.charCodeAt(nOffset + 2);
			if(nRemainingBytes < 3 || //   not   enough   data 
				(iCode1 & 0xC0) != 0x80 || //   invalid   pattern 
				(iCode2 & 0xC0) != 0x80) {
				break;
			}

			bstr += String.fromCharCode(((iCode & 0x0F) << 12) |
				((iCode1 & 0x3F) << 6) |
				(iCode2 & 0x3F));
			nOffset += 3;
			nRemainingBytes -= 3;
		} else //   4   or   more   bytes   --   unsupported 
			break;
	}

	if(nRemainingBytes != 0) {
		//   bad   UTF8   string. 
		return "";
	}

	return bstr;

}

function utf8CodeToChineseChar(strUtf8) {
	var iCode, iCode1, iCode2;
	iCode = parseInt("0x" + strUtf8.substr(1, 2));
	iCode1 = parseInt("0x" + strUtf8.substr(4, 2));
	iCode2 = parseInt("0x" + strUtf8.substr(7, 2));
	return String.fromCharCode(((iCode & 0x0F) << 12) |
		((iCode1 & 0x3F) << 6) |
		(iCode2 & 0x3F));
}

function replace(str, a, b) {
	var i;
	var s2 = str;

	while(s2.indexOf(a) > 0) {
		i = s2.indexOf(a);
		s2 = s2.substring(0, i) + b +
			s2.substring(i + 2, s2.length);
	}
	return s2;
}

function loginOut() {
	localStorage.setItem('account', JSON.stringify(''));
	localStorage.setItem('password', JSON.stringify(''));
	localStorage.setItem('passwordDate', JSON.stringify(''));
	window.location.href = "login.html";
}

function getNowFormatDate() {
	var date = new Date();
	var seperator1 = "-";
	var seperator2 = ":";
	var month = date.getMonth() + 1;
	var strDate = date.getDate();
	if(month >= 1 && month <= 9) {
		month = "0" + month;
	}
	if(strDate >= 0 && strDate <= 9) {
		strDate = "0" + strDate;
	}
	var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
		" " + date.getHours() + seperator2 + date.getMinutes();
	return currentdate;
}

//设备佩戴
function equipmentWearing(){
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.page = "1";
	map.size = "20";
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "wearingList",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowWearData', JSON.stringify(bb.data));
				window.location = "设备佩戴.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
	
}
//佩戴搜索
function equipmentWearingSearch(){
	var equipmentSeach = $("#cowWearData").val();
	console.log(equipmentSeach);
	if(equipmentSeach.indexOf("请输入搜索内容") != -1) {
		mui.toast("请输入您的搜索内容");
		equipmentWearing();
	}
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.searchKey = equipmentSeach;
	map.page = "1";
	map.size = "20";
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "wearingList",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowWearData', JSON.stringify(bb.data));
				window.location = "设备佩戴.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
	
}
//添加设备佩戴
function addequipmentWearing(){
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "getWearing",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('addCowWearData', JSON.stringify(bb.data));
				localStorage.setItem('equipmentID', JSON.stringify(1));
				window.location = "添加设备佩戴.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//设备取下
function equipmentRemoval(){
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.page = "1";
	map.size = "20";
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "takeDownList",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowRemoveData', JSON.stringify(bb.data));
				window.location = "设备取下.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//设备取下搜索
function equipmentRemoveSearch(){
	var equipmentSeach = $("#cowRemoveData").val();
	console.log(equipmentSeach);
	if(equipmentSeach.indexOf("请输入搜索内容") != -1) {
		mui.toast("请输入您的搜索内容");
		equipmentRemoval();
	}
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.searchKey = equipmentSeach;
	map.page = "1";
	map.size = "20";
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "takeDownList",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowRemoveData', JSON.stringify(bb.data));
				window.location = "设备取下.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
	
}
//添加设备取下
function addequipmentRemove(){
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "getTakeDown",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('addCowRemoveData', JSON.stringify(bb.data));
				localStorage.setItem('equipmentID', JSON.stringify(1));
				window.location = "添加设备取下.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//设备更换
function equipmentReplacement(){
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.page = "1";
	map.size = "20";
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "changeList",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowReplacementData', JSON.stringify(bb.data));
				window.location = "设备更换.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//设备更换搜索
function equipmentReplacementSearch(){
	var equipmentSeach = $("#cowReplacementData").val();
	console.log(equipmentSeach);
	if(equipmentSeach.indexOf("请输入搜索内容") != -1) {
		mui.toast("请输入您的搜索内容");
		equipmentReplacement();
	}
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.searchKey = equipmentSeach;
	map.page = "1";
	map.size = "20";
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "changeList",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('cowReplacementData', JSON.stringify(bb.data));
				window.location = "设备更换.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
	
}
//添加设备更换
function addequipmentReplacement(){
	var keys = JSON.parse(localStorage.getItem('key'));
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	showDialog() 
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "getChange",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				localStorage.setItem('addCowReplacementData', JSON.stringify(bb.data));
				localStorage.setItem('equipmentID', JSON.stringify(1));
				window.location = "添加设备更换.html";
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//病牛预警
function bnyj(){
	var keys = JSON.parse(localStorage.getItem('key'));
	//var keys = "07E80800A7EAF270";
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	showDialog()
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "getYsList",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
			   var arr = bb.data;
			   if(arr.length > 3){
				   mui.alert("数据错误");
			   }else{
				   for(var i = 0;i < arr.length;i++){
					   if(arr[i].status === "0"){
						   //疑似
						   $("#bnyj").html(arr[i].number);
					   }else if(arr[i].status === "1"){
						   //未病
					   }else{
						   //有病
						   $("#bnjf").html(arr[i].number);
					   }
				   }
			   }
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//病牛预警详情
function bnyj_info(){
	$(".iinfo").empty();
	var keys = JSON.parse(localStorage.getItem('key'));
	//var keys = "07E80800A7EAF270";
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	map.overbit = localStorage.getItem('overbit_') == null? "" : localStorage.getItem('overbit_');
	showDialog()
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "getYs",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				 console.log(bb)
			     var str = "";
				 var arr = bb.data;
				 for(var i = 0;i<arr.length;i++){
					 str += "<div class='mui-card'>" + 
					        "<div class='mui-card-header'>"+ arr[i].serial +"</div>" +
						    "<div class='mui-card-content'>" +
						    "<div><span class='dd'>奶牛耳号</span><span class='ddd'>"+arr[i].overbit+"</span></div>" + 
						    "<div><span class='dd'>揭发时间</span><span class='timee'>"+getMyDate(parseInt(arr[i].exposeTime.time))+"</span></div>" + 
						    "<div><span class='dd'>类型</span><span class='dddd'>"+arr[i].type+"</span></div>" + 
						    "<div><span class='dd'>牛舍</span><span class='ns'>"+arr[i].house+"</span></div>" + 
						    "</div>" +
							"<div class='mui-card-footer' style='text-align:center;color: #169BD5'><p id='yssb' onclick='yssb("+arr[i].id+",\""+arr[i].serial+"\")'>疑似生病</p></div>" + 
							"</div>";
				 }
				 $(".iinfo").append(str);
						   
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//病牛揭发详情
function bnjf_info(){
	$(".iinfo").empty();
	var keys = JSON.parse(localStorage.getItem('key'));
	//、var keys = "07E80800A7EAF270";
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	map.overbit = localStorage.getItem('overbit_jf') == null? "" : localStorage.getItem('overbit_jf');
	showDialog()
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "getQz",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
				 console.log(bb)
			     var str = "";
				 var arr = bb.data;
				 for(var i = 0;i<arr.length;i++){
					 str += "<div class='mui-card'>" + 
					        "<div class='mui-card-header'>"+ arr[i].serial +"</div>" +
						    "<div class='mui-card-content'>" +
						    "<div><span class='dd'>奶牛耳号</span><span class='ddd'>"+arr[i].overbit+"</span></div>" + 
						    "<div><span class='dd'>揭发时间</span><span class='timee'>"+getMyDate(parseInt(arr[i].exposeTime.time))+"</span></div>" + 
						    "<div><span class='dd'>类型</span><span class='dddd'>"+arr[i].type+"</span></div>" + 
							"<div><span class='dd'>病因</span><span class='dddd'>"+arr[i].mark+"</span></div>" + 
						    "<div><span class='dd'>牛舍</span><span class='ns'>"+arr[i].house+"</span></div>" + 
							"<div><span class='dd'>操作人</span><span class='ddddd'>"+arr[i].operator+"</span></div>" + 
						    "</div>" +
							"<div class='mui-card-footer' style='text-align:center;color: #169BD5'><p id='yssb'></p></div>" + 
							"</div>";
				 }
				 $(".iinfo").append(str);
						   
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//按钮
function toBnyj(){
	var keys = JSON.parse(localStorage.getItem('key'));
	if(keys == "" || keys == null){
		mui.alert("用户凭证不存在");　　　　
	}
	window.location = "病牛预警.html";
}

function toBnjf(){
	var keys = JSON.parse(localStorage.getItem('key'));
	if(keys == "" || keys == null){
		mui.alert("用户凭证不存在");　　　　
	}
	window.location = "病牛揭发.html";
}

function getMyDate(str) {
    let oDate = new Date(str),
    oYear = oDate.getFullYear(),
    oMonth = oDate.getMonth()+1,
    oDay = oDate.getDate(),
    oHour = oDate.getHours(),
    oMin = oDate.getMinutes(),
    oSen = oDate.getSeconds(),
    oTime = oYear +'-'+ addZero(oMonth) +'-'+ addZero(oDay) +' '+ addZero(oHour) +':'+
addZero(oMin) +':'+addZero(oSen);
    return oTime;
}
//补零操作
function addZero(num){
    if(parseInt(num) < 10){
        num = '0'+num;
    }
    return num;
}

function yssb(id,serial){
	localStorage.setItem("bb_id",id);
	localStorage.setItem("bb_serial",serial);
	$("#bb_serial").html(serial + "判定揭发情况");
	//调用隐藏/显示弹出层
	mui("#popover").popover('show', document.getElementById("aa"));	 
}

function qx(){
	 mui("#popover").popover('hide', document.getElementById("aa"));	 
}

function pdwsb(){
	var id = localStorage.getItem("bb_id");
	var serial = localStorage.getItem("bb_serial");
	var keys = JSON.parse(localStorage.getItem('key'));
	//var keys = "07E80800A7EAF270";
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	map.id = id;
	map.status = "1";
	map.mark = "";
	showDialog()
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "updateYs",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
			   if(bb.data[0].success = '成功'){
				   window.reload();
			   }
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}
//生病原因
function pdsb_list(){
	var keys = JSON.parse(localStorage.getItem('key'));
	//var keys = "07E80800A7EAF270";
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	showDialog()
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "getBy",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
			   console.log(bb);
			   var arr = bb.data;
			   var str = "";
			   for(var i = 0;i<arr.length;i++){
				   str += "<ul class='mui-table-view'>" + 
				   "<li class='mui-table-view-cell' onclick='xz(\""+arr[i].dict_label+"\")'>"+arr[i].dict_label+"</li>" + 
				   "</ul>";
			   }
			   $("#sbyy_info").append(str);
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

function pdsb(){
	 window.location = "生病原因.html";
}

function xz(value){
	var id = localStorage.getItem("bb_id");
	var keys = JSON.parse(localStorage.getItem('key'));
	//var keys = "07E80800A7EAF270";
	var map = {};
	map.key = keys;
	map.phoneType = "android";
	map.language = "zh";
	map.id = id;
	map.status = "2";
	map.mark = value;
	showDialog()
	var jsonStr = JSON.stringify(map);
	var ajaxTimeoutTest = $.ajax({
		type: "POST",
		url: url_prefix + "updateYs",		
		dataType: 'JSON',
		timeout: 10000,
		data: {
			'request': encryptByDES(jsonStr)
		},
		success: function(data) {
			dismissDialog();
			var str1 = decryptByDESModeEBC(data["result"]); //解密
			var params = str1.replace(/\+/g, " "); //去掉字符串里的+号
			var str2 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
			var datas = JSON.stringify(str2); //转JSON字符串
			var aa = datas.replace(/\\n/g, " "); //去掉换行
			var objs = eval('(' + aa + ')');
			var bb = eval('(' + objs + ')');
			if(bb.head.status == 1) {
			  if(bb.data[0].success = '成功'){
			  	window.history.back();
			  }
			} else {
				mui.alert(bb.head.info);
			}
		},
		complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
			dismissDialog();　　
			if(status == 'timeout') { //超时,status还有success,error等值的情况
				　　　　　
				ajaxTimeoutTest.abort();　　　　　
				mui.alert("网络请求超时...");　　　　
			}　　
		}
	});
}

function findsearchCow(data){
	var overbit = $("#search_input").val();
	if(data === '1'){
		localStorage.setItem("overbit_",overbit);
		bnyj_info(); 
	}else{
		localStorage.setItem("overbit_jf",overbit);
		bnjf_info(); 
	}
}

function gotohistory(data){
	if(data === '1'){
		localStorage.removeItem("overbit_");
		window.history.back();
	}else{
		localStorage.removeItem("overbit_jf");
		window.history.back();
	}
}